import { post } from '@/http/axios'
// import { enCamelCase, IsArray } from '@/util'
import { handleData, normalTree } from '@/util/data'
// import store from '@/vue/store'

// systemConfigType
export const getConfig = (...args) => post('/searchSystemConfigField', ...args)

// systemConfigType
const config = [
  ['id', 'parent_id', 'parent_id'],
  ['id', 'pid', 'parent_id']
]
export const getConfigData = async (form, tree) => {
  const { code, data, cancelMessage } = await post(
    '/searchSystemConfigList',
    form
  )
  if (data)
    return {
      code,
      data: tree ? normalTree(handleData(data, config, { all: true })) : data,
      cancelMessage
    }

  return {
    code,
    cancelMessage
  }
}

// systemConfigType 1-10
export const addConfigData = (...args) => post('/addSystemConfig', ...args)

export const editConfigData = (...args) => post('/editSystemConfig', ...args)

export const delConfigData = (...args) => post('/removeSystemConfig', ...args)
// removeSystemConfig
